<?php
include "includes/sesiones.php";
include "includes/comunes.php";

if($_GET['act']==1){

  $sql="UPDATE clientes
   SET Nombre = '".strtoupper(trim($_POST['nombre']))."'
      ,Apellido = '".strtoupper(trim($_POST['apellido']))."'
      ,Dni = '".strtoupper(trim($_POST['dni']))."'
      ,Calle = '".strtoupper(trim($_POST['calle']))."'
      ,Numero = '".strtoupper(trim($_POST['numero']))."'
      ,Piso = '".strtoupper(trim($_POST['piso']))."'
      ,Dpto = '".strtoupper(trim($_POST['dpto']))."'
      ,EntreCalles = '".strtoupper(trim($_POST['entrecalles']))."'
      ,TelCel = '".strtoupper(trim($_POST['telcel']))."'
      ,TelFijo = '".strtoupper(trim($_POST['telfijo']))."'
      ,Email = '".strtoupper(trim($_POST['email']))."'
      ,FechaNacimiento = '".strtoupper($_POST['nac'])."'
      ,Provincia = ".$_POST['provincia']."
      ,Localidad = ".$_POST['localidad']."
      ,CP = '".strtoupper(trim($_POST['cp']))."'
      ,IngresoMensual = ".number_format($_POST['ingreso'],2,".","")."
      WHERE id=".$_GET['cli_id'];
  //echo $sql;die();
      $updcli=  cons_ins($sql);
      //actualizo los dni de los creditos
      actualizo_dni_credito($_POST['dniold'],$_POST['dni']);
      
  header("Location: listadoclientes.php?men=Cliente actualizado exitosamente&cli_id=".$_GET['cli_id']);
}else{

$sql="select * from clientes where id=".$_GET['cli_id'];
$rescli=  cons_ins($sql);
$regcli=mysql_fetch_array($rescli);
}
//elimino credito



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php include "includes/metas.php";?>





<link type="text/css" rel="Stylesheet" href="validar/jquery.validity.css" />
<script type="text/javascript" src="validar/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="validar/jquery.validity.min.js"></script>
<script type="text/javascript">
            $(function() {
                $("form").validity(function() {
                    $("#nombre").require("Ingrese el Nombre")
                    $("#apellido").require("Ingrese el Apellido")
                    $("#dni")
                    .require("Ingrese el Dni")
                    .match("number")
                    .maxLength( 8,"Ingrese el Nº con 8 digitos" )
                    $("#ingreso")
                    .require("Ingrese el Ingreso Mensual")
                    .match("number")
                    $("#telcel")
                    .require("Ingrese el Numero Celular")
                    $("#calle")
                    .require("Ingrese Calle")
                    


                });
            });
        </script>

<script language="JavaScript" type="text/javascript" src="combos/jquery.js"></script>


<script language="JavaScript" type="text/javascript" src="combos/jquery.chainedSelects.js"></script>
<style>
#loading
{
	position:absolute;
	top:0px;
	right:0px;
	background:#ff0000;
	color:#fff;
	font-size:14px;
	font-familly:Arial;
	padding:2px;
	display:none;
}
</style>


<script language="JavaScript" type="text/javascript">
$(function()
{
	$('#provincia').chainSelect('#localidad','combocli.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
//        $('#localidad').chainSelect('#tasas','combobox.php',
//	{
//		before:function (target) //before request hide the target combobox and display the loading message
//		{
//			$("#loading").css("display","block");
//			$(target).css("display","none");
//		},
//		after:function (target) //after request show the target combobox and hide the loading message
//		{
//			$("#loading").css("display","none");
//			$(target).css("display","inline");
//		}
//	});

});
</script>

</head>

<body>
<div class="contenedor">
    <div id="loading">abriendo ...</div>
	<div class="cont">
    	<?php include "includes/head.php";?>
        <?php include "includes/menu.php";?>
            
    	<div class="novedadescont">
             <form id="form" name="form" method="post" action="editarClientes.php?act=1&cli_id=<?php echo $_GET['cli_id']?>">
        	<div class="novedadestitulo">
            	<div class="menuvolver"> <a href="javascript:history.back(1)">Volver Atrás</a></div>
            </div>
                 <div class="novedadestitulo">
            	<div class="novetitulo2">Actualizacion de Datos: <?php echo $regcli['Apellido']?>,  <?php echo $regcli['Nombre']?></div>
            </div>
            <div class="formucont">


<!--                Datos basicos del clientes-->

           	  <div class="formlinea">

                <div class="formtxt">Nombre</div>
                <div class="formtxt2">
                    <label for="form"></label>
                    <input name="nombre" id="nombre" type="text" required="required" disabled autofocus="autofocus" value="<?php echo trim($regcli['Nombre'])?>" size="25" maxlength="50"/>
                  
                </div>
                
                </div>   
                
              <div class="formlinea">
                <div class="formtxt">Apellido</div>
                <div class="formtxt2">
                 
                    <label for="form"></label>
                    <input name="apellido" id="apellido" required="required" disabled autofocus="autofocus" type="text" value="<?php echo trim($regcli['Apellido'])?>" size="25" maxlength="50"/>
                 
                </div>
                
                </div>
                
                
                
              <div class="formlinea">
                <div class="formtxt">Nº DNI</div>
                <div class="formtxt2">
                 <div class="ui-widget">
                    <label for="form"></label>
                    <input name="dni" required="required" disabled autofocus="autofocus" id="dni" value="<?php echo trim($regcli['Dni'])?>" type="text" size="25" maxlength="8"/>
                   <input name="dniold" id="dni" disabled value="<?php echo trim($regcli['Dni'])?>" type="hidden" size="25" maxlength="8"/>
                 </div>
                </div>
                
                </div>

               <div class="formlinea">
                <div class="formtxt">Fecha Nac.</div>
                <div class="formtxt2">
                 <div class="ui-widget">
                    <label for="form"></label>
                    <input name="nac" id="nac" type="text" disabled size="25" value="<?php echo trim($regcli['FechaNacimiento'])?>" placeholder="yyyy-mm-dd" maxlength="10"/>
                 </div>
                </div>

                </div>
                
                
                
              <div class="formlinea">
                <div class="formtxt">
                    Tel.Fijo
                </div>
                <div class="formtxt2">
                 
                    <label for="form"></label>
                    <input name="telfijo" id="telfijo" type="text" disabled size="25" value="<?php echo trim($regcli['TelFijo'])?>" maxlength="20"/>
                 
                </div>
                
                </div>
                
                
                
              <div class="formlinea">
                <div class="formtxt">Tel. Cel</div>
                <div class="formtxt2">
                  
                    <label for="form"></label>
                    <input name="telcel" type="text"  disabled required="required" autofocus="autofocus" size="25" value="<?php echo trim($regcli['TelCel'])?>" maxlength="20"/>
                  
                </div>
                
                </div>


                 <div class="formlinea">
                <div class="formtxt">Email</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <input name="email" type="text"  disabled size="25" value="<?php echo trim($regcli['Email'])?>" maxlength="20"/>

                </div>

                </div>

<!--fin datos basicos del cliente-->

<!--Datos de ubicacion-->

 <div class="novedadestitulo3">
            	<div class="novetitulo3">Ubicacion</div>
            </div>
                <div class="formlinea">
                <div class="formtxt">Calle</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <input name="calle" id="calle" disabled type="text" size="25" value="<?php echo trim($regcli['Calle'])?>" maxlength="50"/>

                </div>

                </div>

               <div class="formlinea">
                <div class="formtxt">Nro</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <input name="numero" id="numero" disabled type="text" size="15" value="<?php echo trim($regcli['Numero'])?>" maxlength="5"/>

                </div>

                </div>

                <div class="formlinea">
                <div class="formtxt">Piso</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <input name="piso" id="piso" disabled type="text" size="15" value="<?php echo trim($regcli['Piso'])?>" maxlength="5"/>

                </div>

                </div>

                <div class="formlinea">
                <div class="formtxt">Dpto</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <input name="dpto" id="dpto" disabled type="text" size="15" value="<?php echo trim($regcli['Dpto'])?>" maxlength="5"/>

                </div>

                </div>

                 <div class="formlinea">
                <div class="formtxt">Barrio</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <input name="entrecalles" disabled id="entrecalles" type="text" size="25" value="<?php echo trim($regcli['EntreCalles'])?>" maxlength="50"/>

                </div>

                </div>

                 <div class="formlinea">
                <div class="formtxt">Codigo Postal</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <input name="cp" id="cp" disabled type="text" required="required" autofocus="autofocus" size="15" value="<?php echo trim($regcli['CP'])?>" maxlength="5"/>

                </div>

                </div>

               <div class="formlinea">
                <div class="formtxt">Provincia</div>
                <div class="formtxt2">

                    <label for="form"></label>


                    <select name="provincia" id="provincia" disabled>
                       
                        <?php
                        $sqlfin="select  * from provincia order by id desc";
                        $resfin= cons_ins($sqlfin);
                        while ($regpro=mysql_fetch_array($resfin)){
                            if($regpro['id']==$regcli['Provincia'])
                                    $sel="selected";
                            else
                                $sel="";
                            echo "<option value='".$regpro['id']."' ".$sel.">".trim(utf8_encode($regpro['Nombre']))."</option>";
                            
                         }

                        ?>
                    </select>

                </div>

                </div>


               <div class="formlinea">
                <div class="formtxt">Localidad</div>
                <div class="formtxt2">

                    <label for="form"></label>

                    <select name="localidad" id="localidad" disabled>

                        <?php
                        $sqlloc="select  * from localidades where idProvincia=".$regcli['Provincia']." order by id desc";
                        $resloc= cons_ins($sqlloc);
                        while ($regloc=mysql_fetch_array($resloc)){
                            if($regloc['id']==$regcli['Localidad'])
                                    $sel="selected";
                            else
                                $sel="";
                            echo "<option value='".$regloc['id']."' ".$sel.">".trim(utf8_encode($regloc['Nombre']))."</option>";
                           
                         }

                        ?>
                    </select>

                </div>

                </div>


<!--Fin datos de ubicacion-->

                 <div class="novedadestitulo3">
            	<div class="novetitulo3">Datos de Laborales</div>
            </div>
                <div class="formlinea">
                <div class="formtxt">Ingreso Mensual</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <input name="ingreso" id="ingreso" disabled type="text" size="25" value="<?php echo $regcli['IngresoMensual']?>" maxlength="10"/>

                </div>

                </div>





		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <!-- <input name="guardar" class="bot" type="submit" value="Actualizar" /> -->
               
                         
            </div>           
            
            
            
        	<div class="novedadesbottom"></div>
                </form>
        </div>
    
    
    
    
    <div class="separador"></div>
    <?php include "includes/menufooter.php";?>
    
    
    
	<div id="clearing"></div>    
    </div>
<div id="clearing"></div>
</div>
</body>
</html>
